package easy;

import java.util.Arrays;

public class a1984_学生分数的最小差值 {
    public int minimumDifference(int[] nums, int k) {
        Arrays.sort(nums);
        int n=nums.length;
        int ans=nums[k-1]-nums[0];
        for (int i = k; i < n; i++) {
            ans=Math.min(ans,nums[i]-nums[i-k+1]);
        }
        return  ans;
    }
}
